package com.lcm.jnode.helpers;

import java.sql.Timestamp;

import com.jfinal.kit.StringKit;
import com.lcm.jnode.kit.StringsKit;
import com.lcm.jnode.utils.DateUtil;
import com.lcm.jnode.utils.HtmlFilter;


/**
 * Jade4J 标签 帮助
 * @author L.cm
 * @param <T>
 * @date Aug 29, 2013 6:58:35 PM
 */
public class JadeHelper {
	
	// use #{jTag.format(XXXX)}
	public String format(Timestamp tamp) {
		return DateUtil.formatCn(tamp);
	}
	
	// use #{jTag.formatRss(XXXX)}
	public String formatRss(Timestamp tamp) {
		return DateUtil.formartRss(tamp);
	}
	
	// 清除字符串中的html标签
	public String filterText(String string) {
		return HtmlFilter.getText(string);
	}
	
	// 清除字符串中的html标签并截取
	public String filterSubText(String string, int length) {
		return StringsKit.subCn(HtmlFilter.getText(string), length, "...");
	}
	
	// 标记关键字
	public String markKeywords(String string, int length, String keywords) {
		if (StringKit.notBlank(keywords)) {
			return HtmlFilter.markKeywods(keywords, filterSubText(string, length));
		} else {
			return filterSubText(string, length);
		}
	}
}